package com.share.common.utils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class DelayUtil {
    public static void sleepMillis(long millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void sleepRangMillis(int millis_min, int millis_max) {
        long up = (int) (Math.random() * (millis_max - millis_min));
        long millis = (millis_min + up);
        sleepMillis(millis);
    }

    public static void sleepSecond(int second) {
        long millis = second * 1000;
        sleepMillis(millis);
    }

    public static void sleepRangSecond(int second_min, int second_max) {
        long up = (int) (Math.random() * (second_max - second_min));
        long millis = (second_min + up) * 1000;
        sleepMillis(millis);
    }

    public static void sleepMinute(int minute) {
        long millis = minute * 60 * 1000;
        sleepMillis(millis);
    }

    public static void sleepRangMinute(int minute_min, int minute_max) {
        long up = (int) (Math.random() * (minute_max - minute_min));
        long millis = (minute_min + up) * 1000;
        sleepMillis(millis);
    }
}
